Skip to content

feat: Session drilldown feature to Performance & Errors charts - #539

Merged
Blaumaus merged 4 commits into
mainfrom
feature/performance-errors-session-drilldown
May 21, 2026
Merged

feat: Session drilldown feature to Performance & Errors charts#539
Blaumaus merged 4 commits into
mainfrom
feature/performance-errors-session-drilldown

Conversation

@Blaumaus

@Blaumaus Blaumaus commented May 20, 2026

Copy link
Copy Markdown
Member

Changes

If applicable, please describe what changes were made in this pull request.

Community Edition support

  • Your feature is implemented for the Swetrix Community Edition
  • This PR only updates the Cloud (Enterprise) Edition code (e.g. Paddle webhooks, blog, payouts, etc.)

Database migrations

  • Clickhouse / MySQL migrations added for this PR
  • No table schemas changed in this PR

Documentation

  • You have updated the documentation according to your PR
  • This PR did not change any publicly documented endpoints

Summary by CodeRabbit

  • New Features

    • Click data points on error, performance, traffic, and goal charts to open a sessions drawer for that timeframe (improved targeting and labels)
    • Sessions drawer supports goal-scoped and error-affected session views, accurate counts, pagination, and mode-specific rendering
    • Filter sessions by event type (traffic, performance, error); goal-specific session fetches and error-session filtering respect timezone and filters
  • Documentation

    • Added guidance and API docs for drilling from charts into sessions and the new goal sessions endpoint

Review Change Stack

@Blaumaus Blaumaus self-assigned this May 20, 2026
@Blaumaus Blaumaus changed the title Feature/performance errors session drilldown feat: Session drilldown feature to Performance & Errors charts May 20, 2026
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4865865c-a224-425c-bf9e-ea9b51a403b2

📥 Commits

Reviewing files that changed from the base of the PR and between 03df4aa and f271c35.

📒 Files selected for processing (1)
  • backend/apps/cloud/src/analytics/analytics.service.ts

📝 Walkthrough

Walkthrough

Adds chart datapoint click-to-open sessions: frontend click handlers and time-window computation, SessionsDrawer multi-mode fetching (standard/goal/error) with sessionEvent forwarding, backend controller/service query branching for event types, API/proxy updates, and docs.

Changes

Chart Data Point Exploration with Session Filtering

Layer / File(s) Summary
Session Event Type System
backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts, backend/apps/community/src/analytics/dto/get-sessions.dto.ts, backend/apps/cloud/src/analytics/analytics.controller.ts, backend/apps/community/src/analytics/analytics.controller.ts, backend/apps/cloud/src/analytics/analytics.service.ts, backend/apps/community/src/analytics/analytics.service.ts
Add sessionEvent DTO fields and SessionsListEventType; controllers map sessionEvent → sessionDataType and forward sessionEvent to service calls.
Analytics Service Query Filtering
backend/apps/cloud/.../analytics.service.ts, backend/apps/community/.../analytics.service.ts
getSessionsList and buildSessionsListPrimaryEventsSubquery accept sessionEvent and primaryEventFilterQuery; SQL branches to use custom_event or events.type = sessionEvent and injects primaryEventFilterQuery. getErrorAffectedSessions accepts filtersQuery/filtersParams and merges them into count/sessions queries.
Goal Sessions Endpoints
backend/apps/cloud/src/goal/goal.controller.ts, backend/apps/community/src/goal/goal.controller.ts
New GET /goal/:id/sessions endpoints with authorization, period/from/to/timezone resolution, match/meta conditions, clamped pagination, and analyticsService.getSessionsList usage; return { sessions, take, skip }.
Error Sessions Filtering
backend/apps/cloud/src/analytics/analytics.controller.ts, backend/apps/community/src/analytics/analytics.controller.ts
Controllers destructure filters/timezone, build filtersQuery/filtersParams via getFiltersQuery(DataType.ERRORS), compute safeTimezone, and pass filters into getErrorAffectedSessions.
Chart Point Utilities
web/app/pages/Project/View/utils/chartPoint.ts
New exports: ChartDataPointClick, attachDataPointClickHandlers (SVG hover/click handling and nearest-circle indexing), and getChartPointWindow (timezone-aware from/to and label for time buckets).
Chart Helpers & Wiring
web/app/pages/Project/View/ViewProject.helpers.tsx
Refactor getSettings/getSettingsError/getSettingsPerf to accept onDataPointClick and dataPointClickLabel, wire onclick/onrendered to attachDataPointClickHandlers, extend tooltips, and adjust point focus/sensitivity.
Chart Components
web/app/pages/Project/tabs/* (Errors, Performance, Traffic, Goals)
Chart components accept optional onDataPointClick props and computed localized dataPointClickLabel; pass them into settings builders and include in memo deps so charts update when click behavior changes.
SessionsDrawer Multi-Mode
web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx, web/app/api/api.server.ts
SessionsDrawer supports goal/error/standard modes; fetchSessionsPage accepts rootParams; post-fetch normalization distinguishes error-affected sessions and standard sessions, tracks resultTotalCount and hasMore, and uses title/badge rendering logic.
View Integration & Click Handlers
web/app/pages/Project/tabs/Errors/ErrorsView.tsx, web/app/pages/Project/tabs/Performance/PerformanceView.tsx, web/app/pages/Project/tabs/Goals/GoalsView.tsx, web/app/pages/Project/tabs/Traffic/TrafficView.tsx
Views compute chart-click time windows via getChartPointWindow, manage sessionsDrawer state (from/to/label and optional goalId/errorId/sessionEvent), and render SessionsDrawer with proper params.
Server API & Proxy Route
web/app/api/api.server.ts, web/app/routes/api.analytics.ts
Added SessionEventType, GoalSessionsResponse, and getGoalSessionsServer; getSessionsServer accepts sessionEvent. Proxy route adds getGoalSessions action and forwards sessionEvent; getErrorSessions proxy forwards filters/timezone.
ToolsController cleanup
backend/apps/cloud/src/tools/tools.controller.ts
Removed IP_LOOKUP analytics tracking and user-agent extraction; lookupIP returns result directly.
Docs
docs/content/docs/api/stats.mdx, docs/content/docs/analytics-dashboard/*.mdx
API docs: optional sessionEvent on GET /v1/log/sessions; new GET /goal/:id/sessions docs. Dashboard docs: note that clicking chart points opens the affected sessions for that window.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐇 I tap a chart, a datapoint gleams,
The drawer opens — sessions, dreams.
Traffic, perf, or errors shown,
From spike to session now I roam.
Thump-thump, the rabbit finds the trace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main feature added: a session drilldown capability for Performance and Errors charts.
Description check ✅ Passed The description follows the template structure with all required sections completed: Changes section (checked), Community Edition support (checked as implemented), Database migrations (checked as not needed), and Documentation (checked as updated).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/performance-errors-session-drilldown

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx`:
- Around line 71-95: mapErrorSession is coercing ErrorAffectedSession into a
full SessionType by inserting synthetic zeros/defaults which produces misleading
UI; instead stop fabricating missing data: change mapErrorSession to return the
original ErrorAffectedSession shape (or a SessionType variant with the
truly-missing fields set to null/undefined) and update getResultSessions to
return the sessions as their real shape (e.g., union type SessionType |
ErrorAffectedSession) so the UI can render an error-specific row or display
"unknown" for missing fields rather than showing zero/default values; reference
mapErrorSession and getResultSessions when making these changes.
- Around line 193-207: The getErrorSessions branch calls fetchSessionsPage with
'getErrorSessions' but does not pass the active dashboard filters, causing
drilled sessions to ignore filtering; update the call in SessionsDrawer (the
branch using fetchSessionsPage('getErrorSessions', ...)) to include the current
filter payload (the same filter object used for the generic sessions query) so
the error-specific endpoint receives the same { period, from, to, timezone,
take, skip, ...filters, errorId } — alternatively, if the error endpoint cannot
accept filters, change the branch to call the generic sessions query (e.g.,
fetchSessionsPage('getSessions', ...)) when any dashboard filters are active so
drilled sessions respect the activeFilters.

In `@web/app/pages/Project/View/utils/chartPoint.ts`:
- Around line 48-49: The guard using eventRectsGroup.__clickAttached prevents
reattaching listeners and causes closures to capture stale
columns/onDataPointClick; replace the boolean flag with a versioned marker tied
to the current handler/data (for example store eventRectsGroup.__clickHandlerId
= `${columnsHash}:${onDataPointClickId}`) and only skip attaching when the
stored id matches the current one, or always remove existing listeners before
reattaching; update the logic in the block that sets
eventRectsGroup.__clickAttached (and the similar logic in lines 51-97) to use
this versioned marker or explicit removal so clicks use the latest columns and
onDataPointClick closures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c6a95463-b45e-4968-b2b2-bfc1b2a5b738

📥 Commits

Reviewing files that changed from the base of the PR and between d9e053f and e41c94a.

📒 Files selected for processing (25)
  • backend/apps/cloud/src/analytics/analytics.controller.ts
  • backend/apps/cloud/src/analytics/analytics.service.ts
  • backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts
  • backend/apps/cloud/src/goal/goal.controller.ts
  • backend/apps/cloud/src/tools/tools.controller.ts
  • backend/apps/community/src/analytics/analytics.controller.ts
  • backend/apps/community/src/analytics/analytics.service.ts
  • backend/apps/community/src/analytics/dto/get-sessions.dto.ts
  • backend/apps/community/src/goal/goal.controller.ts
  • docs/content/docs/analytics-dashboard/error-tracking.mdx
  • docs/content/docs/analytics-dashboard/goals.mdx
  • docs/content/docs/analytics-dashboard/performance.mdx
  • docs/content/docs/api/stats.mdx
  • web/app/api/api.server.ts
  • web/app/pages/Project/View/ViewProject.helpers.tsx
  • web/app/pages/Project/View/utils/chartPoint.ts
  • web/app/pages/Project/tabs/Errors/ErrorChart.tsx
  • web/app/pages/Project/tabs/Errors/ErrorsView.tsx
  • web/app/pages/Project/tabs/Goals/GoalsView.tsx
  • web/app/pages/Project/tabs/Performance/PerformanceChart.tsx
  • web/app/pages/Project/tabs/Performance/PerformanceView.tsx
  • web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx
  • web/app/pages/Project/tabs/Traffic/TrafficChart.tsx
  • web/app/pages/Project/tabs/Traffic/TrafficView.tsx
  • web/app/routes/api.analytics.ts
💤 Files with no reviewable changes (1)
  • backend/apps/cloud/src/tools/tools.controller.ts

Comment thread web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx Outdated
Comment thread web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx
Comment thread web/app/pages/Project/View/utils/chartPoint.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/apps/cloud/src/analytics/analytics.service.ts`:
- Around line 6481-6489: The params object spreads filtersParams after explicit
keys which allows filter keys to inadvertently override critical query params;
change the construction of the params object so that ...filtersParams is spread
first and then explicit keys (pid, eid, groupFrom, groupTo, take, skip, ...) are
set afterwards (e.g., use { ...filtersParams, pid, eid, groupFrom, groupTo,
take, skip }) to ensure the explicit values in the params constant take
precedence over any entries produced by getFiltersQuery().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bfebb664-25ee-4b76-a7b8-29961d71b348

📥 Commits

Reviewing files that changed from the base of the PR and between e41c94a and 03df4aa.

📒 Files selected for processing (10)
  • backend/apps/cloud/src/analytics/analytics.controller.ts
  • backend/apps/cloud/src/analytics/analytics.service.ts
  • backend/apps/cloud/src/analytics/dto/get-error.dto.ts
  • backend/apps/community/src/analytics/analytics.controller.ts
  • backend/apps/community/src/analytics/analytics.service.ts
  • backend/apps/community/src/analytics/dto/get-error.dto.ts
  • web/app/api/api.server.ts
  • web/app/pages/Project/View/utils/chartPoint.ts
  • web/app/pages/Project/tabs/Traffic/SessionsDrawer.tsx
  • web/app/routes/api.analytics.ts

Comment thread backend/apps/cloud/src/analytics/analytics.service.ts
@Blaumaus
Blaumaus merged commit 319e434 into main May 21, 2026
12 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 4, 2026
6 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jul 11, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant